package com.itheima.appserver.service;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.appserver.interceptor.UserThreadLocal;
import com.itheima.commons.pojo.mongo.Album;
import com.itheima.dubbo.interfaces.AlbumApi;
import org.bson.types.ObjectId;
import org.springframework.stereotype.Service;

/**
 * @author yaohu
 * @date 2021/12/7
 * @Version 1.0
 * @describe
 */
@Service
public class AlbumService {

    @Reference
    private AlbumApi albumApi;

    public void save(ObjectId id) {
        Album album = new Album();

        album.setId(new ObjectId());
        album.setPublishId(id);
        album.setCreated(System.currentTimeMillis());
        Long userId = UserThreadLocal.getUserId();

        albumApi.saveAlbum(album, userId);
    }
}
